# -*- coding: utf-8 -*-  
import os
import time

#引入飞桨生态的语音和GAN依赖
from PaddleTools.TTS import TTSExecutor
from PaddleTools.GAN import wav2lip


# 文生图
def txt2video(txt2img_prompt, txt2img_img):
    timestamp = str(int(time.time()))
    save_path = os.path.join("/home/aistudio/shuziren2d/file/output", timestamp,"_temp.mp4")
    TTS = TTSExecutor('../default.yaml') #PaddleSpeech语音合成模块
    wavfile = TTS.run(text=txt2img_prompt,output='output.wav') #合成音频
    video = wav2lip(txt2img_img,'output.wav',save_path) #将音频合成到唇形视频

    os.remove(wavfile) #删除临时的音频文件
    print('视频生成完毕，输出路径为：{}'.format(save_path))    

    return video